Pin GitHub Actions to full-length commit SHAs - #2212
Dan Fiedler (danfiedler-msft) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes are limited to workflow/config hardening, and the updated YAML in both files is well-formed and aligned with the stated security goal.
Pull request overview
This PR improves CI supply-chain security and reproducibility by pinning third-party GitHub Actions to full-length commit SHAs and configuring Dependabot to update GitHub Actions with a 7-day cooldown.
Changes:
- Pin
actions/checkout,actions/setup-dotnet, andactions/upload-artifactin the CI workflow to full-length commit SHAs (with version comments). - Add a
github-actionsDependabot update configuration withcooldown.default-days: 7.
File summaries
| File | Description |
|---|---|
| .github/workflows/ci-test.yml | Replaces mutable action tags with full-length commit SHA pins for the CI workflow. |
| .github/dependabot.yml | Adds Dependabot github-actions updates with grouping and a 7-day cooldown window. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
I am not happy with this as it doesn't make sense for this circumstance.
First of all, those are trusted action steps, second of all, this is just the CI action where no IP is added into the already public code, the build is the same as anyone can do on their fork.
I would understand pinning SHAs for the release build but not CI where floating versions are actually better security wise because of auto-patching
Dan Fiedler (@danfiedler-msft) Travis Plunk (@TravisEz13) can you provide context around this PR
|
It kinda depends what the default actions permissions on this repo are whether this is really dangerous. The workflow doesn't declare its permissions, so it gets at least Due to how Actions authenticates to Azure and possibly other places like Nuget and Powershell Gallery, depending on how the repo is setup, an attacker could gain access to (temporary) publishing tokens or the OIDC identity of the repo. Because a threat actor could force-push these floating tags to malware, supply chain attack, credential stealers, it could be used to gain access to this repository and what it has access to. Open source best practices are to pin them and rely on dependabot to keep them up to date. Dependabot can now also add a cooldown period, which causes supply chain attacks to have a much smaller window of attack. Updating actions/checkout to Even trusted actions, can cause problems, as the azure functions action that got compromised before the summer. Azure, Microsoft or GitHub are unfortunately also not immune. |
Summary
This PR pins GitHub Actions to full-length commit SHAs for improved security and reproducibility and adds a 7 day cooldown to Dependabot configuration for GitHub Actions. This work is described in more detail at https://aka.ms/action-pinning.
Why?
Pinning actions to commit SHAs prevents supply-chain attacks where a tag could be moved to point to malicious code. This is a recommended security best practice per the GitHub Actions security hardening guide.
This change mitigates the risk of tag retargeting to malicious code as seen in incidents like the tj-actions/changed-files action compromise or codfish/semantic-release-action compromise and improves the integrity and reproducibility of the CI/CD pipeline.
What changed?
Action pinning: Third-party action references in
.github/workflows/that used mutable tag-based references (e.g.,actions/checkout@v4) have been updated to full-length commit SHAs with a version comment (e.g.,actions/checkout@<sha> # v4) using the pinact tool. References that were already pinned to a SHA, or that used immutable release tags, were left unchanged.Dependabot configuration:
.github/dependabot.ymlhas been updated to ensure agithub-actionspackage-ecosystem section is present with acooldownconfiguration (default-days: 7). If the file did not exist, it was created. If agithub-actionssection already existed, only thecooldownblock was added or itsdefault-daysvalue was increased to 7 if it was lower. The 7-day cooldown provides a window for the community to detect and report compromised releases before they are automatically proposed as updates, reducing exposure to supply-chain attacks via newly published malicious versions.Is this safe to merge?
Yes. The pinned SHAs correspond to the same commits that the existing tags pointed to. No behavioral changes in action execution are introduced. You can verify the pinned SHA value using the GitHub REST API (e.g., the commit hash for
actions/checkout@v7can be found in theshaproperty in the JSON response forGET https://api.github.com/repos/actions/checkout/commits/v7).Additional Information
For more information, please see https://aka.ms/action-pinning